﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Input;

namespace RTS
{
	class MainBuilding : Building
	{
		private RTSBuilderBuildingTextures builderBuildingTextures;

		private BuildOptionsCreator optionsCreator;

		public MainBuilding(GameMain game) : base(game)
		{
			graphPositionOffset = new Position2D(10, -10);
			collisionRadius = 100;
			maxLife = life = 100;

			optionsCreator = new BuildOptionsCreator(options);

			optionsCreator.AddBuildOption(typeof(Barracks));
			optionsCreator.AddBuildOption(typeof(MageTower));

			DefineTextures();
		}

		private void DefineTextures()
		{
			builderBuildingTextures = new RTSBuilderBuildingTextures(new TextureSize(310, 340));

			builderBuildingTextures.Idle = "BarracksSpriteSheetIDLE";
			builderBuildingTextures.Constructing = "BarracksSpriteSheetCONSTRUCTING";
			builderBuildingTextures.Death = "BarracksSpriteSheetDEATH";
			builderBuildingTextures.GraphicInterface = "background for interface";
			builderBuildingTextures.GraphicInterfaceExtended = "extended background for interface";
			builderBuildingTextures.GraphicInterfaceOption = "button for interface";
			builderBuildingTextures.SelectionArea = "Barracks_selection";
			builderBuildingTextures.LifeBar = "Barracks_health bar life";
			builderBuildingTextures.LifeBarBackground = "Barracks_health bar empty";
			builderBuildingTextures.Seleted = "Barracks_selection circle";

			builderBuildingTextures.LifeBarOffsetX = 80;
			builderBuildingTextures.LifeBarWidth = 150;
		}

		public override void LoadContent(ContentManager Content)
		{
			buildingTextures = builderBuildingTextures;
			base.LoadContent(Content);
		}

		public void build(Type buildingType)
		{
			Building newBuilding = (Building)(Activator.CreateInstance(buildingType, game));
			newBuilding.LoadContent(Content);
			newBuilding.setPosition(pos.clone());
			newBuilding.assignCamera(camera);
			newBuilding.setFollowMouse(true);

			game.addBuilding(newBuilding);
		}


	}
}
